home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Fades ƒ / Circle serendipity fade.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  2.3 KB  |  78 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Circle serendipity fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 2
  32. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  33. #define theWindowWidth (boundsRect.right-boundsRect.left)
  34.  
  35. pascal short CircleSerendipityFade(Rect boundsRect, Pattern *thePattern);
  36.  
  37. /* I haven't the slightest idea why this works.  Hence the name.  -MP */
  38.  
  39. pascal short CircleSerendipityFade(Rect boundsRect, Pattern *thePattern)
  40. {
  41.     Rect            theRect;
  42.     RgnHandle        curregion, boundsRgn, sectrgn;
  43.     Point            zeropoint;
  44.     int                gap;
  45.     
  46.     gap=theWindowHeight/40;
  47.     SetRect(&theRect, boundsRect.left, boundsRect.top-2*theWindowHeight, boundsRect.right,
  48.         boundsRect.bottom-theWindowHeight);
  49.         
  50.     boundsRgn=NewRgn();
  51.     SetRectRgn(boundsRgn, boundsRect.left, boundsRect.top, boundsRect.right, boundsRect.bottom);
  52.     sectrgn=NewRgn();
  53.     curregion=NewRgn();
  54.     SetEmptyRgn(curregion);
  55.     OpenRgn();
  56.         FrameOval(&theRect);
  57.     CloseRgn(curregion);
  58.     zeropoint.v=boundsRect.bottom;
  59.     zeropoint.h=boundsRect.left;
  60.     do
  61.     {
  62.         StartTiming();
  63.         SectRgn(curregion, boundsRgn, sectrgn);
  64.         FillRgn(sectrgn, *thePattern);
  65.         OffsetRgn(curregion, 0, gap);
  66.         TimeCorrection(CorrectTime);
  67.     }
  68.     while (!(PtInRgn(zeropoint, curregion)));
  69.  
  70.     FillRect(&boundsRect, *thePattern);
  71.     
  72.     DisposeRgn(curregion);
  73.     DisposeRgn(boundsRgn);
  74.     DisposeRgn(sectrgn);
  75.     
  76.     return 0;
  77. }
  78.